package mytest;

public class Similar {

	static int[][] f=new int[101][101];
	
	//static int [][] result=new int[101][101];
	
	static String str1,str2; 
	
	static void init()
	{
		for(int i=0;i<=str1.length();i++)f[i][0]=i;
		for(int i=0;i<=str2.length();i++)f[0][i]=i;
	}
	
	static int solve()
	{
		for(int i=1;i<=str1.length();i++)
			for(int j=1;j<=str2.length();j++)
			{
				if(str1.charAt(i-1)==str2.charAt(j-1))
				{
					f[i][j]=f[i-1][j-1];
				}else{
					f[i][j]=Math.min(f[i][j-1], Math.min(f[i-1][j-1], f[i-1][j]))+1;
				}
			}
		return f[str1.length()][str2.length()];
	}
	

	static void print()
	{
		for(int i=0;i<=str1.length();i++)
		{
			for(int j=0;j<=str2.length();j++)
				System.out.print(f[i][j]+" ");
			System.out.println();
		}
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {

		str1="abcde";
		str2="cbce";
		init();
		System.out.println(solve());
		print();
	}

}
